﻿/**  版本信息模板在安装目录下，可自行修改。
* T_DeoSale.cs
*
* 功 能： N/A
* 类 名： T_DeoSale
*
* Ver    变更日期             负责人  变更内容
* ───────────────────────────────────
* V0.01  2017/5/22 17:17:26   N/A    初版
*
* Copyright (c) 2012 Maticsoft Corporation. All rights reserved.
*┌──────────────────────────────────┐
*│　此技术信息为本公司机密信息，未经本公司书面同意禁止向第三方披露．　│
*│　版权所有：动软卓越（北京）科技有限公司　　　　　　　　　　　　　　│
*└──────────────────────────────────┘
*/
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using SYDZ.WMS.DBUtility;
namespace WMSAML.Warehouse.DAL
{
	/// <summary>
	/// 数据访问类:T_DeoSale
	/// </summary>
	public partial class T_DeoSale
	{
		public T_DeoSale()
		{}
		#region  BasicMethod

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("DeoSale_ID", "T_DeoSale"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int DeoSale_ID)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from T_DeoSale");
			strSql.Append(" where DeoSale_ID=@DeoSale_ID");
			SqlParameter[] parameters = {
					new SqlParameter("@DeoSale_ID", SqlDbType.Int,4)
			};
			parameters[0].Value = DeoSale_ID;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(WMSAML.Warehouse.Model.T_DeoSale model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into T_DeoSale(");
			strSql.Append("DeoSale_count,DeoSale_Number,DeoSale_Machine,DeoSale_ShuL,DeoSale_Banshu,DeoSale_meiban,DeoSale_fahuodi,DeoSale_Daban,DeoSale_QF,DeoSale_JQ,DeoSale_UserName,DeoSale_UserTime,DeoSale_Str1,DeoSale_Str2,DeoSale_Str3,DeoSale_Str4,DeoSale_Str5)");
			strSql.Append(" values (");
			strSql.Append("@DeoSale_count,@DeoSale_Number,@DeoSale_Machine,@DeoSale_ShuL,@DeoSale_Banshu,@DeoSale_meiban,@DeoSale_fahuodi,@DeoSale_Daban,@DeoSale_QF,@DeoSale_JQ,@DeoSale_UserName,@DeoSale_UserTime,@DeoSale_Str1,@DeoSale_Str2,@DeoSale_Str3,@DeoSale_Str4,@DeoSale_Str5)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@DeoSale_count", SqlDbType.Int,4),
					new SqlParameter("@DeoSale_Number", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Machine", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_ShuL", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Banshu", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_meiban", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_fahuodi", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Daban", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_QF", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_JQ", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_UserName", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_UserTime", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str1", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str2", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str3", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str4", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str5", SqlDbType.NVarChar,50)};
			parameters[0].Value = model.DeoSale_count;
			parameters[1].Value = model.DeoSale_Number;
			parameters[2].Value = model.DeoSale_Machine;
			parameters[3].Value = model.DeoSale_ShuL;
			parameters[4].Value = model.DeoSale_Banshu;
			parameters[5].Value = model.DeoSale_meiban;
			parameters[6].Value = model.DeoSale_fahuodi;
			parameters[7].Value = model.DeoSale_Daban;
			parameters[8].Value = model.DeoSale_QF;
			parameters[9].Value = model.DeoSale_JQ;
			parameters[10].Value = model.DeoSale_UserName;
			parameters[11].Value = model.DeoSale_UserTime;
			parameters[12].Value = model.DeoSale_Str1;
			parameters[13].Value = model.DeoSale_Str2;
			parameters[14].Value = model.DeoSale_Str3;
			parameters[15].Value = model.DeoSale_Str4;
			parameters[16].Value = model.DeoSale_Str5;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(WMSAML.Warehouse.Model.T_DeoSale model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update T_DeoSale set ");
			strSql.Append("DeoSale_count=@DeoSale_count,");
			strSql.Append("DeoSale_Number=@DeoSale_Number,");
			strSql.Append("DeoSale_Machine=@DeoSale_Machine,");
			strSql.Append("DeoSale_ShuL=@DeoSale_ShuL,");
			strSql.Append("DeoSale_Banshu=@DeoSale_Banshu,");
			strSql.Append("DeoSale_meiban=@DeoSale_meiban,");
			strSql.Append("DeoSale_fahuodi=@DeoSale_fahuodi,");
			strSql.Append("DeoSale_Daban=@DeoSale_Daban,");
			strSql.Append("DeoSale_QF=@DeoSale_QF,");
			strSql.Append("DeoSale_JQ=@DeoSale_JQ,");
			strSql.Append("DeoSale_UserName=@DeoSale_UserName,");
			strSql.Append("DeoSale_UserTime=@DeoSale_UserTime,");
			strSql.Append("DeoSale_Str1=@DeoSale_Str1,");
			strSql.Append("DeoSale_Str2=@DeoSale_Str2,");
			strSql.Append("DeoSale_Str3=@DeoSale_Str3,");
			strSql.Append("DeoSale_Str4=@DeoSale_Str4,");
			strSql.Append("DeoSale_Str5=@DeoSale_Str5");
			strSql.Append(" where DeoSale_ID=@DeoSale_ID");
			SqlParameter[] parameters = {
					new SqlParameter("@DeoSale_count", SqlDbType.Int,4),
					new SqlParameter("@DeoSale_Number", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Machine", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_ShuL", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Banshu", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_meiban", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_fahuodi", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Daban", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_QF", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_JQ", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_UserName", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_UserTime", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str1", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str2", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str3", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str4", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_Str5", SqlDbType.NVarChar,50),
					new SqlParameter("@DeoSale_ID", SqlDbType.Int,4)};
			parameters[0].Value = model.DeoSale_count;
			parameters[1].Value = model.DeoSale_Number;
			parameters[2].Value = model.DeoSale_Machine;
			parameters[3].Value = model.DeoSale_ShuL;
			parameters[4].Value = model.DeoSale_Banshu;
			parameters[5].Value = model.DeoSale_meiban;
			parameters[6].Value = model.DeoSale_fahuodi;
			parameters[7].Value = model.DeoSale_Daban;
			parameters[8].Value = model.DeoSale_QF;
			parameters[9].Value = model.DeoSale_JQ;
			parameters[10].Value = model.DeoSale_UserName;
			parameters[11].Value = model.DeoSale_UserTime;
			parameters[12].Value = model.DeoSale_Str1;
			parameters[13].Value = model.DeoSale_Str2;
			parameters[14].Value = model.DeoSale_Str3;
			parameters[15].Value = model.DeoSale_Str4;
			parameters[16].Value = model.DeoSale_Str5;
			parameters[17].Value = model.DeoSale_ID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int DeoSale_ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_DeoSale ");
			strSql.Append(" where DeoSale_ID=@DeoSale_ID");
			SqlParameter[] parameters = {
					new SqlParameter("@DeoSale_ID", SqlDbType.Int,4)
			};
			parameters[0].Value = DeoSale_ID;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string DeoSale_IDlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from T_DeoSale ");
			strSql.Append(" where DeoSale_ID in ("+DeoSale_IDlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WMSAML.Warehouse.Model.T_DeoSale GetModel(int DeoSale_ID)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 DeoSale_ID,DeoSale_count,DeoSale_Number,DeoSale_Machine,DeoSale_ShuL,DeoSale_Banshu,DeoSale_meiban,DeoSale_fahuodi,DeoSale_Daban,DeoSale_QF,DeoSale_JQ,DeoSale_UserName,DeoSale_UserTime,DeoSale_Str1,DeoSale_Str2,DeoSale_Str3,DeoSale_Str4,DeoSale_Str5 from T_DeoSale ");
			strSql.Append(" where DeoSale_ID=@DeoSale_ID");
			SqlParameter[] parameters = {
					new SqlParameter("@DeoSale_ID", SqlDbType.Int,4)
			};
			parameters[0].Value = DeoSale_ID;

			WMSAML.Warehouse.Model.T_DeoSale model=new WMSAML.Warehouse.Model.T_DeoSale();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				return DataRowToModel(ds.Tables[0].Rows[0]);
			}
			else
			{
				return null;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WMSAML.Warehouse.Model.T_DeoSale DataRowToModel(DataRow row)
		{
			WMSAML.Warehouse.Model.T_DeoSale model=new WMSAML.Warehouse.Model.T_DeoSale();
			if (row != null)
			{
				if(row["DeoSale_ID"]!=null && row["DeoSale_ID"].ToString()!="")
				{
					model.DeoSale_ID=int.Parse(row["DeoSale_ID"].ToString());
				}
				if(row["DeoSale_count"]!=null && row["DeoSale_count"].ToString()!="")
				{
					model.DeoSale_count=int.Parse(row["DeoSale_count"].ToString());
				}
				if(row["DeoSale_Number"]!=null)
				{
					model.DeoSale_Number=row["DeoSale_Number"].ToString();
				}
				if(row["DeoSale_Machine"]!=null)
				{
					model.DeoSale_Machine=row["DeoSale_Machine"].ToString();
				}
				if(row["DeoSale_ShuL"]!=null)
				{
					model.DeoSale_ShuL=row["DeoSale_ShuL"].ToString();
				}
				if(row["DeoSale_Banshu"]!=null)
				{
					model.DeoSale_Banshu=row["DeoSale_Banshu"].ToString();
				}
				if(row["DeoSale_meiban"]!=null)
				{
					model.DeoSale_meiban=row["DeoSale_meiban"].ToString();
				}
				if(row["DeoSale_fahuodi"]!=null)
				{
					model.DeoSale_fahuodi=row["DeoSale_fahuodi"].ToString();
				}
				if(row["DeoSale_Daban"]!=null)
				{
					model.DeoSale_Daban=row["DeoSale_Daban"].ToString();
				}
				if(row["DeoSale_QF"]!=null)
				{
					model.DeoSale_QF=row["DeoSale_QF"].ToString();
				}
				if(row["DeoSale_JQ"]!=null)
				{
					model.DeoSale_JQ=row["DeoSale_JQ"].ToString();
				}
				if(row["DeoSale_UserName"]!=null)
				{
					model.DeoSale_UserName=row["DeoSale_UserName"].ToString();
				}
				if(row["DeoSale_UserTime"]!=null)
				{
					model.DeoSale_UserTime=row["DeoSale_UserTime"].ToString();
				}
				if(row["DeoSale_Str1"]!=null)
				{
					model.DeoSale_Str1=row["DeoSale_Str1"].ToString();
				}
				if(row["DeoSale_Str2"]!=null)
				{
					model.DeoSale_Str2=row["DeoSale_Str2"].ToString();
				}
				if(row["DeoSale_Str3"]!=null)
				{
					model.DeoSale_Str3=row["DeoSale_Str3"].ToString();
				}
				if(row["DeoSale_Str4"]!=null)
				{
					model.DeoSale_Str4=row["DeoSale_Str4"].ToString();
				}
				if(row["DeoSale_Str5"]!=null)
				{
					model.DeoSale_Str5=row["DeoSale_Str5"].ToString();
				}
			}
			return model;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select DeoSale_ID,DeoSale_count,DeoSale_Number,DeoSale_Machine,DeoSale_ShuL,DeoSale_Banshu,DeoSale_meiban,DeoSale_fahuodi,DeoSale_Daban,DeoSale_QF,DeoSale_JQ,DeoSale_UserName,DeoSale_UserTime,DeoSale_Str1,DeoSale_Str2,DeoSale_Str3,DeoSale_Str4,DeoSale_Str5 ");
			strSql.Append(" FROM T_DeoSale ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" DeoSale_ID,DeoSale_count,DeoSale_Number,DeoSale_Machine,DeoSale_ShuL,DeoSale_Banshu,DeoSale_meiban,DeoSale_fahuodi,DeoSale_Daban,DeoSale_QF,DeoSale_JQ,DeoSale_UserName,DeoSale_UserTime,DeoSale_Str1,DeoSale_Str2,DeoSale_Str3,DeoSale_Str4,DeoSale_Str5 ");
			strSql.Append(" FROM T_DeoSale ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM T_DeoSale ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.DeoSale_ID desc");
			}
			strSql.Append(")AS Row, T.*  from T_DeoSale T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "T_DeoSale";
			parameters[1].Value = "DeoSale_ID";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  BasicMethod
		#region  ExtensionMethod

		#endregion  ExtensionMethod
	}
}

